package com.usian.controller;

import com.sun.org.apache.regexp.internal.RE;
import com.usian.pojo.TbContent;
import com.usian.pojo.TbContentCategory;
import com.usian.pojo.TbItemCat;
import com.usian.service.ContentService;
import com.usian.utils.AdNode;
import com.usian.utils.PageResult;
import com.usian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/service/content")
public class ContentControllet {

    @Autowired
    ContentService contentService;

    @RequestMapping("selectFrontendContentByAD")
    public List<AdNode> selectFrontendContentByAD(){
        return contentService.selectFrontendContentByAD();
    }


    @RequestMapping("deleteContentByIds")
    public Integer deleteContentByIds(@RequestParam Long ids){
        return contentService.deleteContentByIds(ids);
    }

    /**
     * 内容管理  添加接口
     *
     * @param tbContent
     * @return
     */
    @RequestMapping("/insertTbContent")
    public Integer insertTbContent(@RequestBody TbContent tbContent){
        return contentService.insertTbContent(tbContent);
    }

    /**
     * 内容管理查询接口
     *
     * @param categoryId
     * @param pages
     * @param rows
     * @return
     */
    @RequestMapping("selectTbContentAllByCategoryId")
    public PageResult selectTbContentAllByCategoryId(@RequestParam Long categoryId, @RequestParam Integer pages,
                                              @RequestParam Integer rows){
        return contentService.selectTbContentAllByCategoryId(categoryId,pages,rows);
    }

    /**
     * 内容分类管理修改接口
     *
     * @param tbContentCategory
     * @return
     */
    @RequestMapping("updateContentCategory")
    Integer updateContentCategory(@RequestBody TbContentCategory tbContentCategory){
        return contentService.updateContentCategory(tbContentCategory);
    }


    @RequestMapping("deleteContentCategoryById")
    public Integer deleteContentCategoryById(@RequestParam("categoryId") Long categoryId){
       return contentService.deleteContentCategoryById(categoryId);
    }


    /**
     * 内容分类管理添加接口
     *
     * @param tbContentCategory
     * @return
     */
    @RequestMapping("insertContentCategory")
    public Integer insertContentCategory(@RequestBody TbContentCategory tbContentCategory){
       return contentService.insertContentCategory(tbContentCategory);
    }


    /**
     * 内容分类管理查询接口
     *
     * @param id
     * @return
     */
    @RequestMapping("selectContentCategoryByParentId")
    public List<TbContentCategory> selectContentCategoryByParentId(@RequestParam("id") Integer id){
        return contentService.selectContentCategoryByParentId(id);
    }

}
